package demo1;


public class Test {
    public static SingleList.ListNode reverseList(SingleList.ListNode head) {
        if(head == null) {
            return head;
        }
        SingleList.ListNode prev = head;
        SingleList.ListNode cur = head.next;

        while(cur != null) {
            SingleList.ListNode tmp = cur.next;
            cur.next = prev;
            prev = cur;
            cur = tmp;
        }

        head.next = null;
        return head;
    }
    public static void main(String[] args) {
        SingleList singleList = new SingleList();
        singleList.addLast(3);
        singleList.addLast(1);
        singleList.addLast(2);
        singleList.addLast(3);
        reverseList(singleList.head);
        singleList.display();
    }
}
